import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);

import {getGoods,getRatings,getSeller} from "../api/api"
export default new Vuex.Store({
    state:{
        goodInfo:{},
        ratingInfo:{},
        sellerInfo:{}
    },
    getters:{},
    mutations:{
        getGoodInfo(state,goodInfo){
            state.goodInfo = goodInfo;
        },
        getRatingsInfo(state,ratingInfo){
            state.ratingInfo = ratingInfo;
        },
        getSellerInfo(state,sellerInfo){
            state.sellerInfo = sellerInfo;
        },
    },
    actions:{
        async getGoodInfo({commit}){
            const {data} = await getGoods();
            commit("getGoodInfo",data)
        },
        async getRatingsInfo({commit}){
            const {data} = await getRatings();
            commit("getRatingsInfo",data)
        },
        async getSellerInfo({commit}){
            const {data} = await getSeller();
            commit("getSellerInfo",data)
        }

    },
    modules:{},
    plugin:{},
})